﻿using System;
using System.ComponentModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using DomusDotNet.Sbm.Client.SL4noCM.Services;

namespace DomusDotNet.Sbm.Client.SL4noCM.ViewModels
{
    public abstract class ViewModelBase : INotifyPropertyChanged
    {
        protected WCFServices.SharedBookshelfServiceClient webService;

        public ViewModelBase()
        {
                this.securityContext = App.SecurityContext;
                if (!DesignerProperties.IsInDesignTool) 
                    webService = new WCFServices.SharedBookshelfServiceClient();
                ErrorMessage = string.Empty;
        }

        protected ISecurityContext securityContext;

        private string errorMessage;
        public string ErrorMessage
        {
            get
            {
                return errorMessage;
            }
            protected set
            {
                if (value != errorMessage)
                {
                    this.errorMessage = value;
                    OnPropertyChanged("ErrorMessage");
                }
            }
        }

        private bool webRequestExecution = false;
        public bool WebRequestExecution
        {
            get
            {
                return webRequestExecution ;
            }
            protected set
            {
                if (value != webRequestExecution)
                {
                    this.webRequestExecution = value;
                    OnPropertyChanged("WebRequestExecution");
                }
            }
        }


        public virtual event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
